#include "dotawindow.h"
#include "ui_dotawindow.h"

DotaWindow::DotaWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::DotaWindow)
{
    ui->setupUi(this);
    int nCount = ui->listWidget_2->count();
    for(int i =0 ;i<nCount ;i++)
    {
        QListWidgetItem *item = ui->listWidget_2->item(i);
        item->setFlags( (item->flags()) | Qt::ItemIsEditable );
        item->setCheckState(Qt::Unchecked);
    }
}

DotaWindow::~DotaWindow()
{
    delete ui;
}

void DotaWindow::on_pushButtonAdd_clicked()
{
    QString strItem = QFileDialog::getOpenFileName(
                this,
                tr("选择装备图标"),
                tr("."),
                tr("Image files(*.jpg *.png *.bmp);;All files(*)")
                );
    if(strItem.isEmpty())
    {
        return;
    }

    QIcon iconNew(strItem);

    QListWidgetItem *item = new QListWidgetItem(
                iconNew,
                tr("新装备名"),
                ui->listWidget_2
                );
    ui->listWidget_2->setCurrentItem(item);
    ui->listWidget_2->editItem(item);
}

void DotaWindow::on_pushButtonDel_clicked()
{
    int uCurRow = ui->listWidget_2->currentRow();
    if(uCurRow < 0 )
    {
        return ;
    }
    QListWidgetItem *item = ui->listWidget_2->takeItem(uCurRow);
    delete item;item=NULL;
}

void DotaWindow::on_pushButtonViewMode_clicked()
{

}

void DotaWindow::on_pushButtonLoad_clicked()
{

}

void DotaWindow::on_pushButtonSave_clicked()
{

}



void DotaWindow::on_listWidget_2_itemChanged(QListWidgetItem *item)
{

}

void DotaWindow::on_listWidget_2_currentItemChanged(QListWidgetItem *current, QListWidgetItem *previous)
{

}
